package com.hzx.security.security;

import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;
import utils.MD5;

@Component
public class DefaultPasswordEncoder implements PasswordEncoder {


    public DefaultPasswordEncoder(){
        this(-1);
    }

    public DefaultPasswordEncoder(int i){

    }

    @Override
    public String encode(CharSequence var1) {

        return MD5.encrypt(var1.toString());
    }


    //和密码比对
    //var1为密码，var2位加密后的密码（MD5是不可逆的）
    @Override
    public boolean matches(CharSequence var1, String var2) {
        return var2.equals(MD5.encrypt(var1.toString()));
    }
}
